home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
listcol
/
frmlistc.frm
(
.txt
)
next >
Wrap
Visual Basic Form
|
1998-10-19
|
3KB
|
82 lines
VERSION 5.00
Begin VB.Form frmListcol
Caption = "Simulated Columns in a VB ListBox"
ClientHeight = 3885
ClientLeft = 3255
ClientTop = 1785
ClientWidth = 6045
LinkTopic = "Form1"
ScaleHeight = 259
ScaleMode = 3 'Pixel
ScaleWidth = 403
Begin VB.PictureBox Separator
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 3375
Index = 1
Left = 2760
ScaleHeight = 3345
ScaleWidth = 345
TabIndex = 2
Top = 0
Width = 375
End
Begin VB.PictureBox Separator
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 3375
Index = 0
Left = 1800
ScaleHeight = 3345
ScaleWidth = 345
TabIndex = 1
Top = 0
Width = 375
End
Begin VB.ListBox List1
Height = 3375
Left = 240
TabIndex = 0
Top = 240
Width = 5535
End
Attribute VB_Name = "frmListcol"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' demo project showing how to set tabstops to simulate virtical
' columns in a listbox using the SendMessage API function
' by Bryan Stafford of New Vision Software
- newvision@imt.net
' this demo is released into the public domain "as is" without
' warranty or guaranty of any kind. In other words, use at
' your own risk.
' the constant we use when telling the listbox where to set the tabstops
Private Const LB_SETTABSTOPS As Long = &H192&
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, _
ByVal wMsg&, ByVal wParam&, lParam As Any)
Private Sub Form_Load()
' move the picture boxes used for column seperators into place over top of the list box
Separator(False).Move List1.Left + ((List1.Width - 4) \ 3), List1.Top + 2, 1, _
List1.Height - 4
Separator(1).Move List1.Left + ((List1.Width - 4) - ((List1.Width - 4) \ 3)), _
List1.Top + 2, 1, List1.Height - 4
ReDim TabStops(1) As Long ' this dimentions the array to two items, 0 and 1
TabStops(0) = 82 ' First Tab stop position
TabStops(1) = 163 ' Second Tab position
' tab widths are figured in "dialog units" which are approxemately
' 1/4 of the width of the average charactor in the currently selected font.
Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 2&, TabStops(0))
' 2& = number of tabs being set, TabStops(0) is first array element
Dim i%
' add some items to the listbox
For i = 1 To 50
List1.AddItem "Item " & CStr(i) & " Column 1" & vbTab & "Item " & CStr(i) & " Column 2" & _
vbTab & "Item " & CStr(i) & " Column 3"
Next
End Sub